cc.Class({
    extends: cc.Component,

    properties: {
        allloading: 0,
    },

    // use this for initialization
    onLoad: function () {
        
    },
    
    onLoading: function () {
        this.onLoadCombinations();
        this.onLoadCards();
        this.onLoadNumber();
    },
    
    //加载卡牌组合
    onLoadCombinations: function () {
        var self = this;
        for (let i = 0; i < 9; i++) {
            cc.loader.loadRes("combinations/combinations_" + i, cc.SpriteFrame, function (err, spriteFrame) {
                cc.spriteFrameCache.addSpriteFrame(spriteFrame, "combinations_" + i);
                self.allloading++;
            });
        }
    },
    
    //加载卡牌
    onLoadCards: function (){
        var self = this;
        for (let i = 2; i < 15; i++) {
            for (let j = 0; j < 4; j++) {
                cc.loader.loadRes("cards/poker_" + (i * 10 + j), cc.SpriteFrame, function (err, spriteFrame) {
                    cc.spriteFrameCache.addSpriteFrame(spriteFrame, "poker_" + (i * 10 + j));
                    self.allloading++;
                });
            }
        }
    },
    
    //加载数字
    onLoadNumber: function () {
        var self = this;
        for (let i = 0; i < 10; i++) {
            cc.loader.loadRes("number/" + i, cc.SpriteFrame, function (err, spriteFrame) {
                cc.spriteFrameCache.addSpriteFrame(spriteFrame, "" + i);
                self.allloading++;
            });
        }
    },
    
    //获得当前的加载数目
    getLoadingNum: function () {
        return this.allloading;
    },
});
